
/**
 * Created by  lizhihang
 */

'use strict';
var express = require('express');
var router = express.Router();
var logger = require('../logger');
var superagent = require('superagent');
var qiniu = require("qiniu");

//需要填写你的 Access Key 和 Secret Key
qiniu.conf.ACCESS_KEY = 'FoiyICSlYLk7vMOBABvfUhyCNEcXf4UoIyxcg5iE';
qiniu.conf.SECRET_KEY = '0Pcetignbpn7MHTSHlMS6-LVBVFwikjyllnSDxXz';




/**
 * Test qiniu
 *
 */
function upFileToken(req, res, next) {
  //上传到七牛后的空间
  var bucket = 'wegdut';

  //生成上传 Token
  var token = uptoken(bucket);
  res.send({uptoken:token})
}

function uptoken(bucket) {
  var putPolicy = new qiniu.rs.PutPolicy(bucket);
  return putPolicy.token();
}


module.exports = { upFileToken };
